package br.net.woodstock.tickettoride.client.jdk6;

import java.util.logging.Level;

import br.net.woodstock.rockframework.InitializationException;
import br.net.woodstock.tickettoride.client.TicketLog;
import br.net.woodstock.tickettoride.client.TicketService;
import br.net.woodstock.tickettoride.client.TicketServiceFactory;
import br.net.woodstock.tickettoride.client.config.TicketConfig;
import br.net.woodstock.tickettoride.client.jdk6.ws.jee.TicketServiceFactoryJEE;

public final class TicketClient {

	private static TicketClient		instance	= new TicketClient();

	private TicketServiceFactory	factory;

	private TicketClient() {
		super();
		try {
			this.factory = new TicketServiceFactoryJEE(TicketConfig.getInstance().getServiceWSDL());
		} catch (Exception e) {
			TicketLog.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
		}
	}

	public TicketService getService() {
		try {
			return this.factory.getTicketService();
		} catch (Exception e) {
			throw new InitializationException(e);
		}
	}

	public static TicketClient getInstance() {
		return TicketClient.instance;
	}

}
